# encoding=utf8
import sys
reload(sys)
sys.setdefaultencoding('utf8')

class JT_9202:
    result=[]
    analysisDescription=['音视频通道号:','回放控制:','快进或快退倍数:','拖动回放位置:']
    analysis9202Length=[1,1,1,6]
    def LogicAisle(self, protocolStr, header):
        count=0
        for i in range(len(self.analysisDescription)):
            s = protocolStr[count:count + (self.analysis9202Length[i]*2)]
            # 回放方式
            if i == 1:
                s = protocolStr[count:count + (self.analysis9202Length[i] * 2)]
                if s == "00":
                    header.append(self.analysisDescription[i] + s + " 开始回放" + "\n")
                elif s == "01":
                    header.append(self.analysisDescription[i] + s + " 暂停回放" + "\n")
                elif s == "02":
                    header.append(self.analysisDescription[i] + s + " 结束回放" + "\n")
                elif s == "03":
                    header.append(self.analysisDescription[i] + s + " 快进回放" + "\n")
                elif s == "04":
                    header.append(self.analysisDescription[i] + s + " 关键帧快退回放" + "\n")
                elif s == "05":
                    header.append(self.analysisDescription[i] + s + " 拖动回放"+ "\n")
                elif s == "06":
                    header.append(self.analysisDescription[i] + s + " 关键帧播放" + "\n")
                count = count + self.analysis9202Length[i] * 2
            # 快进或快退
            elif i == 2:
                if s == "00":
                    header.append(self.analysisDescription[i] + s + " 无效" + "\n")
                elif s == "01":
                    header.append(self.analysisDescription[i] + s + " 1倍" + "\n")
                elif s == "02":
                    header.append(self.analysisDescription[i] + s + " 2倍" + "\n")
                elif s == "03":
                    header.append(self.analysisDescription[i] + s + " 4倍" + "\n")
                elif s == "04":
                    header.append(self.analysisDescription[i] + s + " 8倍" + "\n")
                elif s == "05":
                    header.append(self.analysisDescription[i] + s + " 16倍" + "\n")
                count = count + self.analysis9202Length[i] * 2
            #拖动回放位置
            elif i == 3:
                count3 = 0
                locs = []
                s = protocolStr[count:count + (self.analysis9202Length[i] * 2)]
                for j in range(0, 6):
                    loc = s[count3:count3 + 2]
                    locs.append(loc)
                    count3 = count3 + 2
                header.append(
                    self.analysisDescription[i] + locs[0] + "-" + locs[1] + "-" + locs[2] + "-" + locs[3] + "-" +
                    locs[4] + "-" + locs[5] + "\n")
                count = count + self.analysis9202Length[i] * 2
            else:
                header.append(self.analysisDescription[i] + s + "\n")
                count = count + self.analysis9202Length[i] * 2
        self.result = header

